/**
 * Created by qsyan on 2016-11-27.
 */
import api from '../api'

export const SELECT_ROW = 'SELECT_ROW';
export const LOAD = 'LOAD';
export const LOAD_ALL_PENDING = 'LOAD_ALL_PENDING';
export const LOAD_ALL_SUCCESS = 'LOAD_ALL_SUCCESS';
export const LOAD_ALL = 'LOAD_ALL';
export const GET_BY_ID = 'GET_BY_ID';
export const GET_BY_ID_SUCCESS = 'GET_BY_ID_SUCCESS';

export function del(ids){
 return {
        type: GET_BY_ID,
        payload: {
            promise: api.del('/rest/s1/example/examples',{
                data: {ids : ids.join(',')}
            })
        }
    }
}
export function selectRow(ids, rows) {
    return {
        type: SELECT_ROW,
        payload: {
            data: {"ids": ids, "rows": rows}
        }
    }
}
export function load() {
    return {
        type: LOAD
    }
}
export function get(id) {
    return {
        type: GET_BY_ID,
        payload: {
            promise: api.get('/rest/s1/example/examples/' + id)
        }
    }
}
export function loadAll(pageNo, pageSize) {
    return {
        type: LOAD_ALL,
        payload: {
            promise: api.get('/rest/s1/example/examples', {
                params: {pageNo: pageNo, pageSize: pageSize}
            })
        }
    }
}
export function update(map) {
    return {
        type: LOAD_ALL,
        payload: {
            promise: api.post('/rest/s1/example/examples/' + map.exampleId, {
                data: map
            })
        }
    }
}
